/*
 * AltDominadas.java
 *
 * Created on 15 de diciembre de 2001, 05:31 AM
 */

package InterfacesDiscretas;

public class AltDominadas extends javax.swing.JDialog {
    private InterfacesDiscretas.PlataformaDiscreta Padre;
    private InterfacesGenerales.Plataforma Padre2;
    private int[] dominadas;
    private String[] nomAlt;
    public AltDominadas(InterfacesDiscretas.PlataformaDiscreta parent,InterfacesGenerales.Plataforma parent2 ,boolean modal, int[] dominadas, String[] nomAlt) {
        super(parent2, modal);
        this.dominadas = dominadas;
        this.nomAlt = nomAlt;
        Padre = parent;
        Padre2 = parent2;
        initComponents();
        java.awt.Dimension size=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(size.width/3, size.height/3, size.width/4+90, size.height/4+14);
        altDominadas();
    }
    
    
    private void initComponents() {//GEN-BEGIN:initComponents
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setTitle("Alternativas Dominadas");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        jPanel1.setPreferredSize(new java.awt.Dimension(276, 30));
        jLabel1.setForeground(new java.awt.Color(0, 0, 153));
        jLabel1.setText("Las siguientes son las alternativas dominadas:");
        jPanel1.add(jLabel1);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        jScrollPane1.setViewportView(jPanel2);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jButton1.setText("Eliminar Seleccionadas");
        jButton1.setSelected(true);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel3.add(jButton1);

        jButton3.setText("Cancelar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jPanel3.add(jButton3);

        getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);

        pack();
    }//GEN-END:initComponents
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        int contador = 0;
        for (int i = 0; i < dominadas.length; i ++) {
            if (dominadas[i] == 1 && altDom[i].isSelected()) {
                Padre.getTablaPag().eliminarFilas(i - contador);
                Padre.setNumAlt(Padre.getNumAlt() - 1);
                contador ++;
            }
        }
        DatosEntrada.DatosDiscretos.initDatos(Padre,Padre2 ,Padre.getTablaObj().getModelo().data, Padre.getTablaPag().getModelo().data, Padre.getTablaPag().getVectorColumnas(), Padre.getTablaPag().getValores(), Padre.getTablaPag().getDescripcion(),true);
        Padre.getJDesktopPane1().removeAll();
        setVisible(false);
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed
    
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        Padre.getJDesktopPane1().removeAll();
        setVisible(false);
        dispose();
    }//GEN-LAST:event_jButton3ActionPerformed
    private void altDominadas() {
        int cont = 0;
        for (int i = 0; i < dominadas.length; i++) {
            if (dominadas[i] == 1) {
                cont++;
            }
        }
        altDom = new javax.swing.JCheckBox[dominadas.length];
        
        MyGridBagConstraints = new java.awt.GridBagConstraints[cont];
        int w = 0;
        int k = 0;
        for (int i = 0; i < dominadas.length; i++) {
            if (dominadas[i] == 1) {
                altDom[i] = new javax.swing.JCheckBox(nomAlt[i], true);
                if (k >= 100) {
                    MyGridBagConstraints[k] = new java.awt.GridBagConstraints();
                    int x = (int)(k/100);
                    MyGridBagConstraints[k].gridx = x;
                    MyGridBagConstraints[k].gridy = k - 100*x;
                    MyGridBagConstraints[k].ipady = 5;
                    MyGridBagConstraints[k].ipadx = 5;
                    jPanel2.add(altDom[i], MyGridBagConstraints[k]);
                    k++;
                    w++;
                }
                if (k < 100) {
                    MyGridBagConstraints[k] = new java.awt.GridBagConstraints();
                    MyGridBagConstraints[k].gridx = 0;
                    MyGridBagConstraints[k].gridy = k;
                    MyGridBagConstraints[k].ipady = 5;
                    MyGridBagConstraints[k].ipadx = 5;
                    jPanel2.add(altDom[i], MyGridBagConstraints[k]);
                    k++;
                    w++;
                }
                
            }
            else {
                altDom[i] = new javax.swing.JCheckBox(nomAlt[i], false);
            }
        }
        
    }
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JButton jButton3;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
    private javax.swing.JCheckBox[] altDom;
    private java.awt.GridBagConstraints[] MyGridBagConstraints;
}
